package com.yequan.array;

import com.yequan.compare.Person;
import com.yequan.work.JsonMapper;
import org.apache.commons.collections.CollectionUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author yequan
 * @date 2021/05/11 11:08
 **/
public class ListDemo {

    public static void main(String[] args) {
//        List<Integer> list = new ArrayList<>();
//        list.add(1);
//        list.add(2);
//        list.add(3);
//
//        /*list = clearList(list);
//        for (Integer s : list) {
//            System.out.println(s);
//        }*/
//        List<Integer> newList1 = new ArrayList<>();
//        List<Integer> newList2 =new ArrayList<>();
//        simplifyList(list, newList1, newList2);
//        System.out.println(JsonMapper.toJson(newList1));
//        System.out.println(JsonMapper.toJson(newList2));

//        testGetAllSendTrackRideIdList();
//        sort();
        remove();
    }

    private static void remove(){
        System.out.println(new BigDecimal(1).compareTo(new BigDecimal(2)) < 0);
        Person person1 = new Person(1,12,"李");
        Person person2 = new Person(2,22,"叶");
        Person person3 = new Person(1,12,"李");
        List<Person> list = new ArrayList<>();
        list.add(person1);
        list.add(person2);
        System.out.println(list);
        list.remove(person3);
        System.out.println(list);
    }

    private static List<Integer> clearList(List<Integer> list) {
        if (CollectionUtils.isEmpty(list)) {
            return null;
        }
        List<Integer> newList = new ArrayList<>();
        for (Integer s : list) {
            if (s != 2) {
                newList.add(s);
            }
        }
        return newList;
    }

    public static void simplifyList(List<Integer> list, List<Integer> newList1, List<Integer> newList2) {
        for (Integer num : list) {
            if (num % 2 == 0) {
                newList1.add(num);
            } else {
                newList2.add(num);
            }
        }
    }

    public static void testGetAllSendTrackRideIdList() {
        List<Long> list = new ArrayList<>();
        list.add(1L);
        list.add(2L);
        list.add(3L);
        list.add(4L);
        list.add(5L);
        list.add(6L);
        System.out.println(5 % 2);
        System.out.println(6 % 2);
        long[] ids = getAllSendTrackRideIdList(list);
        System.out.println(JsonMapper.toJson(ids));
    }

    private static long[] getAllSendTrackRideIdList(List<Long> trackEntityList) {
        int halfSize = trackEntityList.size() / 2;
        long[] allSendTrackRideIdList = new long[halfSize];
        for (int i = halfSize; i < trackEntityList.size(); i++) {
            allSendTrackRideIdList[i - halfSize] = trackEntityList.get(i);
        }
        return allSendTrackRideIdList;
    }

    private static void sort() {
        List<Integer> todoList = null;
        Collections.sort(todoList);
    }

}
